package com.hmy.infrastructure.common.properties;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * @author
 * @ClassName OssConfig
 * @Description 阿里云oss配置
 * @date 2019-02-20
 **/
@Data
@Component
@Validated
@ConfigurationProperties(prefix = "aliyun.oss")
public class OssProperties {
    @NotBlank
    private String endpoint;
    @NotBlank
    private String stsEndpoint;
    @NotBlank
    private String accessKeyId;
    @NotBlank
    private String accessKeySecret;
    @NotBlank
    private String bucketName;
    @NotNull
    private Integer expireTime;

    @NotBlank
    private String roleArn;

    /**
     * 服务OSS存储位置配置
     */
    private List<StoreInfo> storeInfos;

    @Data
    public static class StoreInfo {
        /**
         * 服务名称
         */
        private String serviceName;

        private List<BusinessDir> businessDirs;

    }

    @Data
    public static class BusinessDir{
        /**
         * 业务标识
         */
        private String businessKey;
        /**
         * 存储目录
         */
        private String storeDir;
    }
}
